package cn.lesper.process;

import cn.lesper.model.ColumnEntity;
import cn.lesper.model.TableEntity;
import cn.lesper.utils.DatabaseUtils;
import cn.lesper.utils.Nature;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

//数据操作层
public class ExtensibleUtils<T> extends AbstractProcess {


    public boolean insert(Map<String, Object> params){
        String sql = insertSql();
        return databaseUtils.excuteUpdate(sql,params);
    }

    public boolean insert(List<Object> params){
        String sql = insertSql();
        return databaseUtils.excuteUpdate(sql,params);
    }

    public boolean delete(Map<String, Object> params,List<String> condition){
        String sql = updateSql(condition);
        return databaseUtils.excuteUpdate(sql,params);
    }

    public boolean delete(List<Object> params,List<String> condition){
        String sql = updateSql(condition);
        return databaseUtils.excuteUpdate(sql,params);
    }

    public boolean update(Map<String, Object> params,List<String> condition){
        String sql = updateSql(condition);
        return databaseUtils.excuteUpdate(sql,params);
    }

    public boolean update(List<Object> params,List<String> condition){
        String sql = updateSql(condition);
        return databaseUtils.excuteUpdate(sql,params);
    }

    public List<Object> query(Map<String, Object> params) throws IllegalAccessException, NoSuchFieldException, InstantiationException {
        String sql = querySql();
        return databaseUtils.executeQuery(sql,params);
    }

    public List<T> query(Map<String, Object> params,Class<T> clazz) throws IllegalAccessException, NoSuchFieldException, InstantiationException {
        String sql = querySql();
        return databaseUtils.executeQuery(sql,params,clazz);
    }

    public List<Object> query(List<Object> params) throws IllegalAccessException, NoSuchFieldException, InstantiationException {
        String sql = querySql();
        return databaseUtils.executeQuery(sql,params);
    }

    public List<T> query(List<Object> params,Class<T> clazz) throws IllegalAccessException, NoSuchFieldException, InstantiationException {
        String sql = querySql();
        return databaseUtils.executeQuery(sql,params,clazz);
    }


}
